package org.jeecg.modules.friends.dao.impl;

import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.jeecg.modules.friends.condition.MomentsLikeRecordsCondition;
import org.jeecg.modules.friends.condition.SchoolMetaDataCondition;
import org.jeecg.modules.friends.mapper.ext.MomentsLikeRecordsDOExtMapper;
import org.jeecg.modules.friends.model.MomentsLikeRecordsDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MomentsLikeRecordsDAOImpl implements org.jeecg.modules.friends.dao.MomentsLikeRecordsDAO {
    @Autowired
    private MomentsLikeRecordsDOExtMapper momentsLikeRecordsDOExtMapper;

    @Override
    public List<MomentsLikeRecordsDO> queryByMomentsIdAndUserId(List<Long> momentIds, Long userId) {
        MomentsLikeRecordsCondition condition = new MomentsLikeRecordsCondition();
        MomentsLikeRecordsCondition.Criteria criteria = condition.createCriteria();
        criteria.andMomentsIdIn(momentIds);
        criteria.andLikeUserIdEqualTo(userId);
        return momentsLikeRecordsDOExtMapper.selectByCondition(condition);
    }


    @Override
    public MomentsLikeRecordsDO queryOneByMoments(Long momentsId, Long userId) {
        MomentsLikeRecordsCondition condition = new MomentsLikeRecordsCondition();
        MomentsLikeRecordsCondition.Criteria criteria = condition.createCriteria();
        criteria.andMomentsIdEqualTo(momentsId);
        criteria.andLikeUserIdEqualTo(userId);
        List<MomentsLikeRecordsDO> momentsLikeRecordsDOS = momentsLikeRecordsDOExtMapper.selectByCondition(condition);
        return CollectionUtils.isEmpty(momentsLikeRecordsDOS) ? null : momentsLikeRecordsDOS.get(0);
    }

    @Override
    public void insert(MomentsLikeRecordsDO momentsLikeRecordsDO) {
        momentsLikeRecordsDOExtMapper.insert(momentsLikeRecordsDO);
    }

    @Override
    public void update(MomentsLikeRecordsDO momentsLikeRecordsDO) {
        momentsLikeRecordsDOExtMapper.updateByPrimaryKey(momentsLikeRecordsDO);
    }
}
